package com.moefor.clover.init.config;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;

@Configuration
//@PropertySource("classpath:config/Kaptcha.properties")
public class KaptchaConfig {
	@Autowired
    private Environment env;
	
	@Bean(name = "defaultKaptcha")
	public DefaultKaptcha defaultKaptcha(){
		DefaultKaptcha captcha = new DefaultKaptcha();
		Properties properties = new Properties();
		properties.setProperty("kaptcha.border", "no");
		properties.setProperty("kaptcha.image.width", "90");
		properties.setProperty("kaptcha.image.height", "45");
		properties.setProperty("kaptcha.background.clear.from", "255,255,255");
		properties.setProperty("kaptcha.background.clear.to", "255,255,255");
		properties.setProperty("kaptcha.textproducer.char.length", "4");
		properties.setProperty("kaptcha.textproducer.font.size", "35");
		properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
		Config config = new Config(properties);
		captcha.setConfig(config);
		return captcha;
	}
}
